Skip to content

Conversation

@2shrestha22
Copy link

@2shrestha22 2shrestha22 commented Nov 27, 2024

Pull Request

Issue

Closes: #1022

Approach

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling to provide more detailed responses when client connection exceptions occur.
  • Refactor

    • Streamlined internal SDK structure and architecture for improved code organization and maintainability.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 27, 2024

Thanks for opening this pull request!

));
}

if (exception is ClientException) {
Copy link
Member

@mbfakourii mbfakourii Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use two clients, dio and http, at Parse Flutter !

In this change you are using the functions of the http package. Will this not cause any problems when we use the dio package client?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DioException is already being handled above but ClientException was missing.

@mbfakourii
Copy link
Member

@mtrezza

Can you please run CI?

@mtrezza
Copy link
Member

mtrezza commented Nov 30, 2024

@mbfakourii done

@codecov
Copy link

codecov bot commented Nov 30, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 43.47%. Comparing base (c388545) to head (65f624e).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...src/objects/response/parse_exception_response.dart 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1021      +/-   ##
==========================================
+ Coverage   43.37%   43.47%   +0.10%     
==========================================
  Files          61       61              
  Lines        3463     3466       +3     
==========================================
+ Hits         1502     1507       +5     
+ Misses       1961     1959       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtrezza mtrezza changed the title handle http ClientException fix: http client exception not handled properly resulting in incorrect error log Dec 4, 2024
@parse-github-assistant
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title fix: http client exception not handled properly resulting in incorrect error log fix: Http client exception not handled properly resulting in incorrect error log Dec 4, 2024
@mtrezza mtrezza changed the title fix: Http client exception not handled properly resulting in incorrect error log fix: Http client exception not handled properly resulting in incorrectly formatted error Dec 4, 2024
@mtrezza
Copy link
Member

mtrezza commented Dec 4, 2024

I rephrased the PR title; not sure whether it accurately describes the issue, could you please review?

@2shrestha22
Copy link
Author

I think it's better.

@mtrezza
Copy link
Member

mtrezza commented Dec 8, 2024

There is still an open review discussion and the changelog entry + version bump is missing in the PR. See other PRs on how they are done. Then we can go ahead and merge.

@coderabbitai
Copy link

coderabbitai bot commented Nov 15, 2025

📝 Walkthrough

Walkthrough

The changes consolidate the SDK's modularized structure and enhance exception handling. The main library file now imports the http package and removes part directives that previously split functionality across separate files. Additionally, ClientException from the http package is now explicitly handled in response exception processing, converting it to a ParseError.

Changes

Cohort / File(s) Summary
Module restructuring
packages/dart/lib/parse_server_sdk.dart
Added import for http package and removed all part directives, consolidating the previously modularized public API into a single file.
Exception handling
packages/dart/lib/src/objects/response/parse_exception_response.dart
Added new branch in buildParseResponseWithException to handle ClientException, converting it to ParseResponse with ParseError containing the exception's message.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that all previously separated module functionality remains accessible after consolidation and that no circular dependencies or import order issues are introduced
  • Confirm ClientException handling is properly sequenced in the exception chain and test with actual http package exception scenarios

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes an out-of-scope change: removing part directives and collapsing the modularized public API in parse_server_sdk.dart is unrelated to handling ClientException and appears to be a refactoring outside the issue's scope. Revert the changes to parse_server_sdk.dart that remove part directives, or create a separate PR for that refactoring. Keep this PR focused solely on ClientException handling in parse_exception_response.dart.
Description check ❓ Inconclusive The PR description is incomplete. While it references issue #1022, the 'Approach' section lacks implementation details explaining how the fix was implemented. Fill in the 'Approach' section with a detailed description of the changes made to handle ClientException, such as how the exception is now being caught and processed in the response handler.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: handling of HTTP ClientException that was previously not being handled properly, resulting in incorrectly formatted errors.
Linked Issues check ✅ Passed The PR addresses the main objective from issue #1022 by adding ClientException handling in the response builder, converting unhandled exceptions into properly formatted ParseResponse errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@2shrestha22
Copy link
Author

There is still an open review discussion and the changelog entry + version bump is missing in the PR. See other PRs on how they are done. Then we can go ahead and merge.

I thought changelog and version bump should be maintained on release instead of PR merge.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/dart/lib/parse_server_sdk.dart (1)

12-12: Narrow http import to avoid potential symbol clashes with dio

Given this is the root library for many part files and you already import package:dio/dio.dart, bringing in all of package:http/http.dart risks name clashes (e.g., Response) in any part that uses unqualified types.

Since the only thing needed here is ClientException for buildParseResponseWithException, consider narrowing the import:

-import 'package:http/http.dart';
+import 'package:http/http.dart' show ClientException;

This keeps the namespace clean while still enabling the new exception handling.

Please double‑check that no other symbols from http are used anywhere in the parts of this library before applying this change.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec71870 and 54a0f68.

📒 Files selected for processing (2)
  • packages/dart/lib/parse_server_sdk.dart (1 hunks)
  • packages/dart/lib/src/objects/response/parse_exception_response.dart (1 hunks)
🔇 Additional comments (1)
packages/dart/lib/src/objects/response/parse_exception_response.dart (1)

25-29: ClientException handling looks correct and aligns with existing patterns

The new ClientException branch cleanly maps http client errors into a ParseError, consistent with the generic fallback (no explicit error code, message taken from the exception) and separate from the richer DioException handling above.

Functionally this should resolve the issue where ClientException.toString() was previously exposed.

Please confirm:

  • That you have a test covering a thrown ClientException and asserting the resulting ParseResponse.error.message.
  • That no additional metadata (e.g., a specific error code) is needed for ClientException beyond what the generic fallback already provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http ClientException is not handled

3 participants